/*
 * File Name     : @(#)AbstractEvent.java
 * Creation Date : Mar 2, 2009
 * Author        : anirudh
 * 
 * Copyright 2009 Anirudh Vyas
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package hcis.core.engine.event.impl;

import hcis.core.engine.event.IEvent;
import hcis.dto.IDTO;
import hcis.model.IModel;
import hcis.model.annotation.HCISEntity;

import java.io.Serializable;

/**
 * Abtract event serves as a base class for all the events, providing with generic and common functional pieces for other events to re-use or build upon.
 * 
 * @author avyas
 * @param <SOURCE>
 *            DTO source type.
 * @param <MODEL>
 *            model type.
 * @param <MODELID>
 *            model id type.
 */
@HCISEntity
public abstract class AbstractEvent<SOURCE extends IDTO<MODEL, MODELID>, MODEL extends IModel<MODELID>, MODELID extends Serializable> implements IEvent<SOURCE, MODEL, MODELID> {

	/**
	 * Default serial version UID.
	 */
	private static final long serialVersionUID = 1L;

	/**
	 * Bound model to the event.
	 */
	private MODEL boundModel;

	/**
	 * Event source.
	 */
	private SOURCE eventSource;

	/**
	 * Default constructor, sets in bound model and event source.d
	 * 
	 * @param pBoundModel
	 *            bound model.
	 * @param pEventSource
	 *            event source.
	 */
	protected AbstractEvent(final MODEL pBoundModel, final SOURCE pEventSource) {
		super();
		this.boundModel = pBoundModel;
		this.eventSource = pEventSource;
	}

	/**
	 * {@inheritDoc}
	 */
	public final SOURCE getSource() {
		return this.eventSource;
	}

	/**
	 * {@inheritDoc}
	 */
	public final void setSource(final SOURCE pSource) {
		this.eventSource = pSource;
	}

	/**
	 * {@inheritDoc}
	 */
	public final MODEL getBoundModel() {
		return boundModel;
	}

	/**
	 * {@inheritDoc}
	 */
	public final void setBoundModel(final MODEL pModel) {
		boundModel = pModel;
	}
}
